﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GzipManagerPro.UI.Controls.Preview
{
    public static class Factory
    {
        public static PreviewBase Create(string path)
        {
            string extension = Path.GetExtension(path);
            PreviewBase result = null;
            switch (extension)
            {
                case ".txt":
                case ".log":
                case ".ini":
                case ".xml":
                case ".html":
                case ".htm":
                case ".sql":
                case ".rtf":

                    result = new TextPreview();
                    break;

                case ".jpg":
                case ".png":
                case ".jpeg":
                case ".gif":
                case ".bmp":
                case ".tiff":
                case ".wmf":
                case ".emf":

                    result = new PicturePreview();
                    break;

                case GzipManagerPro.IO.Archive.Extension:
                    result = new ArchivePreview();
                    break;

                default:

                    result = new NoPreview();
                    break;
            }

            result.GeneratePreview(path);
            return result;
        }
    }
}
